import Vue from 'vue';
import Router from 'vue-router';
import login from '@/views/login/login';
import select from '@/views/roleSelect/roleSelect';
import dean from '@/router/role/dean';
import guideTeacher from '@/router/role/guideTeacher';
import reviewTeacher from '@/router/role/reviewTeacher';
import thesisSecretary from '@/router/role/thesisSecretary';
import defenseSecretary from '@/router/role/defenseSecretary';
import defenseTeamLeader from '@/router/role/defenseTeamLeader';

Vue.use(Router);

const router = new Router({
  mode: 'history',
  routes: [
    {
      path: '/',
      redirect: '/login',
    },

    // 登录接口
    {
      path: '/login',
      component: login,
    },

    // 角色选择接口
    {
      path: '/select',
      component: select,
    },

    // 系主任路由模块
    ...dean,

    // 指导老师路由模块
    ...guideTeacher,

    // 评阅老师路由模块
    ...reviewTeacher,

    // 论文秘书路由模块
    ...thesisSecretary,

    // 答辩秘书路由模块
    ...defenseSecretary,

    // 答辩组组长路由模块
    ...defenseTeamLeader,
  ],
});

// // 挂载路由导航守卫
// router.beforeEach((to, from, next) => {
//   // to 将要访问的路径
//   // from 代表从哪个路径而来
//   // next 是一个函数，表示放行
//   // next()：放行    next('/login)：强制跳转
//   if (to.path === '/login') return next();

//   // 获取 token
//   const tokenStr = window.sessionStorage.getItem('token');
//   if (!tokenStr) return next('/login');
//   next();
// });

export default router;
